using UnityEngine;

public class AdvertisementHandler : MonoBehaviour
{
	public enum AdvSize
	{
		BANNER,
		IAB_MRECT,
		IAB_BANNER,
		IAB_LEADERBOARD,
		DEVICE_WILL_DECIDE
	}

	public enum AdvOrientation
	{
		VERTICAL,
		HORIZONTAL
	}

	public enum Position
	{
		NO_GRAVITY = 0,
		CENTER_HORIZONTAL = 1,
		LEFT = 3,
		RIGHT = 5,
		FILL_HORIZONTAL = 7,
		CENTER_VERTICAL = 0x10,
		CENTER = 17,
		TOP = 48,
		BOTTOM = 80,
		FILL_VERTICAL = 112
	}

	public enum AnimationInType
	{
		SLIDE_IN_LEFT,
		FADE_IN
	}

	public enum AnimationOutType
	{
		SLIDE_OUT_RIGHT,
		FADE_OUT
	}

	public enum Activity
	{
		INSTANTIATE,
		DISABLE,
		ENABLE,
		HIDE,
		SHOW,
		ENABLE2
	}

	public enum LevelOfDebug
	{
		NONE,
		LOW,
		HIGH
	}

	private static AndroidJavaClass pluginClass;

	private static AndroidJavaClass unityPlayer;

	private static AndroidJavaObject currActivity;

	private static bool setupped;

	private static bool instantiated;

	public static float lastTime = 10f;

	public static float lastBannerTime;

	public static int lastAdType = 1;

	public static void SetupEnvironment()
	{
		lastTime = 10f;
		lastBannerTime = 0f;
		setupped = false;
		pluginClass = new AndroidJavaClass("fi.Miksumortti.SpinTops.PluginActivity");
		unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		currActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
		setupped = true;
		if (PlayerPrefs.GetInt("tmp") != 7)
		{
			CheckConsent();
		}
	}

	public static void InstantiateDefault()
	{
		Instantiate("ca-app-pub-2206560899144969/3764982555", AdvSize.BANNER, AdvOrientation.HORIZONTAL, Position.BOTTOM, Position.LEFT, isTesting: false, AnimationInType.SLIDE_IN_LEFT, AnimationOutType.FADE_OUT, LevelOfDebug.HIGH);
	}

	public static void Instantiate(string pubID, AdvSize advSize, AdvOrientation advOrient, Position position_1, Position position_2, bool isTesting, AnimationInType animIn, AnimationOutType animOut, LevelOfDebug levelOfDebug)
	{
		SetupEnvironment();
		pluginClass.CallStatic("RequestHandler", 7, currActivity);
		if (PlayerPrefs.GetInt("tmp") != 7 && PlayerPrefs.GetInt("tmp") != 7)
		{
			pluginClass.CallStatic("RequestHandler", 0, currActivity, pubID, (int)advSize, (int)advOrient, (int)position_1, (int)position_2, isTesting, (int)animIn, (int)animOut, (int)levelOfDebug);
			instantiated = true;
		}
	}

	public static void CheckConsent()
	{
		if (setupped)
		{
			pluginClass.CallStatic("CheckConsent", currActivity);
		}
	}

	public static void ShowConsentForm()
	{
		if (setupped)
		{
			pluginClass.CallStatic("ShowConsentForm", currActivity);
		}
	}

	public static void EnableAds()
	{
		if (setupped)
		{
			if (instantiated)
			{
				pluginClass.CallStatic("RequestHandler", 2, currActivity);
			}
			else
			{
				InstantiateDefault();
			}
		}
		lastAdType = 0;
	}

	public static void DisableAds()
	{
		if (setupped)
		{
			pluginClass.CallStatic("RequestHandler", 1, currActivity);
		}
	}

	public static void HideAds()
	{
		if (setupped)
		{
			pluginClass.CallStatic("RequestHandler", 3, currActivity);
		}
	}

	public static void ShowAds()
	{
		if (setupped)
		{
			pluginClass.CallStatic("RequestHandler", 4, currActivity);
		}
	}

	public static void RefreshAds()
	{
		if (setupped)
		{
			pluginClass.CallStatic("RefreshAd", currActivity);
		}
	}

	public static void EnableAds2()
	{
		if (setupped)
		{
			pluginClass.CallStatic("RequestHandler", 5, currActivity);
		}
		lastAdType = 1;
	}

	public static void ShareS()
	{
		if (setupped)
		{
			pluginClass.CallStatic("Share", currActivity);
		}
	}

	public static void HideBar()
	{
	}

	public static void ShowInterstitial()
	{
		if (setupped)
		{
			pluginClass.CallStatic("RequestHandler", 8, currActivity, string.Empty);
		}
	}

	public static void PreloadInterstitial()
	{
		if (setupped)
		{
			pluginClass.CallStatic("PreloadInterstitial", currActivity, string.Empty);
		}
	}

	public static void PreloadRewardedInterstitial()
	{
		if (setupped)
		{
			pluginClass.CallStatic("PreloadRewardedInterstitial", currActivity, string.Empty);
		}
	}

	public static void ShowPreloadedInterstitial(bool rewarded)
	{
		if (setupped)
		{
			pluginClass.CallStatic("ShowPreloadedInterstitial", currActivity, rewarded);
		}
	}

	public static void BindBilling()
	{
		pluginClass.CallStatic("RequestHandler", 9, currActivity);
	}

	public static void UnbindBilling()
	{
		pluginClass.CallStatic("RequestHandler", 10, currActivity);
	}

	public static void TestBilling()
	{
		pluginClass.CallStatic("RequestHandler", 11, currActivity);
	}

	public static void BuySpintops()
	{
		BindBilling();
		pluginClass.CallStatic("RequestHandler", 12, currActivity);
	}

	public static void CheckPurchase()
	{
		BindBilling();
		pluginClass.CallStatic("RequestHandler", 13, currActivity);
	}
}
